package com.itheima.edu.info.manager.service;

import com.itheima.edu.info.manager.dao.TeacherDao;
import com.itheima.edu.info.manager.domain.Teacher;

public class TeacherService {
    TeacherDao teacherDao = new TeacherDao();
    Teacher teacher = new Teacher();

    public boolean addTeacher(Teacher teacher) {
        boolean result = teacherDao.addTeacher(teacher);
        return result;
    }

    public boolean isExists(String id) {
        Teacher[] newTeacherArr = teacherDao.getTeacherArr();
        for (int i = 0; i < newTeacherArr.length; i++) {
            Teacher teacher = newTeacherArr[i];
            if(teacher != null && id.equals(teacher.getId())){
                return true;
            }
        }
        return false;
    }

    public Teacher[] findAllTeacher() {
        Teacher[] teachers = teacherDao.findAllTeacher();
        return teachers;
    }

    public void deleteTeacherById(String id) {
        teacherDao.deleteTeacherById(id);
    }

    public void updateTeacher(Teacher teacher, String id) {
        teacherDao.updateTeacher(teacher, id);
    }
}
